--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  3_SingleWomen_regPrep.log
  log type:  text
 opened on:  16 Apr 2018, 08:59:52

. ***************************************************************************;
. * REGRESSION PREP ;
. ***************************************************************************;
. local beginTime "DateTime: $S_DATE $S_TIME";

. set more off ;

. set linesize 200 ;

. set mem 5g ;
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. cd "$dataDir" ;

. ***************************************************************************;
. * MERGE POLICY MEASURES, AND OTHER CONTROLS;
. ***************************************************************************;
. use cpsAfterTaxsim ;

. * CHILDREN ;
. gen children = min(qualChild,3) ;

. tab children ;

   children |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    197,046       54.44       54.44
          1 |     73,544       20.32       74.76
          2 |     56,384       15.58       90.34
          3 |     34,966        9.66      100.00
------------+-----------------------------------
      Total |    361,940      100.00

. * TAX - THESE USE CPS DATA ;
. sort year state children ;

. merge m:1 year state children using simulatedmeasures ;
(note: variable state was byte, now float to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                        40,858
        from master                    40,735  (_merge==1)
        from using                        123  (_merge==2)

    matched                           321,205  (_merge==3)
    -----------------------------------------

. drop if _merge == 2;
(123 observations deleted)

. drop _merge children ;

. summ *SIV* ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
fedEICSIV_~i |    321,205    784.1319    953.0573          0   3143.289
fedRegTaxS~i |    321,205     2030.77    476.0824   978.7578   2933.046
  ctcSIV_uni |    321,205    334.0951    599.1757          0   2395.467
  amtSIV_uni |    321,205           0           0          0          0
stEICSIV_uni |    321,205     41.8297     149.058          0   1571.645
-------------+---------------------------------------------------------
stRegTaxSI~i |    321,205    644.3783    399.8245          0    2081.07
stCredSIV_~i |    321,205    64.24231    139.0655  -260.7329   1184.794
 afdcSIV_uni |    321,205    2580.451    3507.123          0   20072.68
fedEIC~82cps |    321,205    467.1426    555.1395          0   1681.633
fedReg~82cps |    321,205    2842.722    1080.885   570.4361    4513.09
-------------+---------------------------------------------------------
ctcSIV_82cps |    321,205    174.9699    296.0321          0   991.6729
amtSIV_82cps |    321,205    .0224188    .1717511          0   4.677181
stEICSIV_8~s |    321,205    24.51943    86.45897          0   840.8169
stRegT~82cps |    321,205    789.8487    516.8488          0   2314.984
stCred~82cps |    321,205    64.08677    142.5195  -156.4005   1357.953
-------------+---------------------------------------------------------
afdcSIV_82~s |    321,205    1038.782    1644.936          0   13290.01
fedEIC~92cps |    321,205    532.4533    644.3245          0   1858.366
fedReg~92cps |    321,205    3408.858    1402.906   662.2939   5554.682
ctcSIV_92cps |    321,205    126.1017    215.1514          0   727.2305
amtSIV_92cps |    321,205    .0046093     .030945          0   .4305427
-------------+---------------------------------------------------------
stEICSIV_9~s |    321,205     28.2428    99.74833          0   929.1832
stRegT~92cps |    321,205    914.9051    612.9835          0   2674.383
stCred~92cps |    321,205    62.82027    142.2866  -153.7278   1348.678
afdcSIV_92~s |    321,205    1083.374    1753.079          0   14000.67

.         * MERGE THE MANY WAIVER VARIABLES  ;
. sort state ;

. merge m:1 state using afdcwaivers ;

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                           361,940  (_merge==3)
    -----------------------------------------

. drop if _merge==2 ;
(0 observations deleted)

. drop _merge ;

. summ afdcwaiver* ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
afdcwaiver~s |    223,267    1995.605    1.065952       1993       1997
afdcwaive~it |    228,019     1997.82    2.438162       1996       2012
afdcwaive~et |    258,712    1995.102    1.244309       1990       1997
afdcwaiver~i |    201,980    1995.129    1.266039       1993       1997
afdcwaiver~v |    232,197    1994.934    1.542398       1990       1997
-------------+---------------------------------------------------------
afdcwaiver~d |    285,639    1993.787    2.369369       1988       1997

. * TRANSFER PROGRAM PARAMETERS FROM UKPRC - NOT SIMULATED;
. sort year state ;

. merge m:1 year state using state_level_variables_from_UKPRC ;

    Result                           # of obs.
    -----------------------------------------
    not matched                         7,861
        from master                     7,861  (_merge==1)
        from using                          0  (_merge==2)

    matched                           354,079  (_merge==3)
    -----------------------------------------

. drop if _merge == 2 ;
(0 observations deleted)

. drop _merge ;

. summ state year pop emp unemp unempr gsp afdcmb2 afdcmb3 afdcmb4 
>         fsmb1 fsmb2 fsmb3 fsmb4 ssimb eitcmax0 eitcmax1 eitcmax2 
>         steitcr steitcref fedminwge stminwge ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       state |    361,940    24.54397    14.63426          1         51
        year |    361,940    1997.441    9.962079       1979       2013
         pop |    354,079    1.01e+07     9591283     401851   3.83e+07
         emp |    354,079     4660254     4347894     170798   1.70e+07
       unemp |    354,079      338472    381096.5       8163    2267908
-------------+---------------------------------------------------------
      unempr |    354,079     6.33808    2.113582        2.3       17.4
         gsp |    354,079    359956.1    435107.7       4856    2202678
     afdcmb2 |    354,079    339.0803     134.318         60        823
     afdcmb3 |    354,079    417.8486    160.9176         96        925
     afdcmb4 |    354,079    491.8885    186.4445        120       1028
-------------+---------------------------------------------------------
       fsmb1 |    354,079    129.4491    41.96241         63        319
       fsmb2 |    354,079    237.6105    77.01801        115        585
       fsmb3 |    354,079    340.5378    110.3553        165        839
       fsmb4 |    354,079    432.5435    140.1162        209       1065
       ssimb |    354,079    494.7077    186.6292          0       1036
-------------+---------------------------------------------------------
    eitcmax0 |    354,079    254.6608     195.341          0        487
    eitcmax1 |    354,079    1990.243    945.5074        500       3250
    eitcmax2 |    354,079    3071.665    1779.457        500       5372
     steitcr |    354,079    .0986676     2.51459          0        110
   steitcref |    354,079    .1731506     .378378          0          1
-------------+---------------------------------------------------------
   fedminwge |    354,079    4.956726    1.336762        3.1       7.25
    stminwge |    354,079    5.031002     1.64462       1.25       9.19

. * MERGE ON FEDERAL POVERTY LINE ;
. *gen othersandchildren = min(famsize , 9);
. gen qualchild = min(qualChild , 8) ;

. gen othersandchildren = 1+qualchild;

. sort year othersandchildren qualchild ;

. merge m:1 year othersandchildren qualchild using FPL ;

    Result                           # of obs.
    -----------------------------------------
    not matched                         9,085
        from master                     7,861  (_merge==1)
        from using                      1,224  (_merge==2)

    matched                           354,079  (_merge==3)
    -----------------------------------------

. drop if _merge ==2 ;
(1,224 observations deleted)

. drop _merge ;

. summ fpl if year == 1993 & othersandchildren==2 & qualchild == 1 ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
         fpl |      1,909       10960           0      10960      10960

. replace fpl = 9960 if year == 1993 & othersandchildren==2 & qualchild == 1 ;
(1,909 real changes made)

. summ fpl if year == 1993 & othersandchildren==5 & qualchild == 3 ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
         fpl |          0

. replace fpl = 17245 if year == 1993 & othersandchildren==5 & qualchild == 3 ;
(0 real changes made)

. summ fpl ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
         fpl |    354,079    10766.96      4237.6       4284      45037

. drop qualchild ;

. * MERGE IN HOUSING SUBSIDY - 1984 onward;
. replace year = year +1 ;
(361,940 real changes made)

. sort year serial pernum ;

. merge 1:1 year serial pernum using housing_sub_cps ;

    Result                           # of obs.
    -----------------------------------------
    not matched                     5,205,527
        from master                    40,735  (_merge==1)
        from using                  5,164,792  (_merge==2)

    matched                           321,205  (_merge==3)
    -----------------------------------------

. drop if _merge == 2;
(5,164,792 observations deleted)

. drop _merge ;

. replace year = year - 1 ;
(361,940 real changes made)

. gen houssub = f_houssub*12 ;
(40,735 missing values generated)

. gen schlunch = f_mv_sl ;
(40,735 missing values generated)

. summ f_houssub houssub;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
   f_houssub |    321,205    14.87562    59.07181          0        600
     houssub |    321,205    178.5074    708.8617          0       7200

. * ADJUST VARIABLES THAT NEED IT FOR INFLATION. SOME ARE ALAREDAY DONE ;
. foreach dollar of varlist gsp afdcmb2 afdcmb3 afdcmb4 
>                 fsmb1 fsmb2 fsmb3 fsmb4 ssimb eitcmax0 eitcmax1 eitcmax2
>                 fedminwge stminwge fpl houssub schlunch {;
  2.         qui replace `dollar' = `dollar' * (232.957/cpi);
  3.         };

. ***************************************************************************;
. * MAKING VARIABLES ;
. ***************************************************************************;
. gen afdcmb = 0 ;

. replace afdcmb = afdcmb2 if qualChild == 1 ;
(73,544 real changes made, 1,400 to missing)

. replace afdcmb = afdcmb3 if qualChild == 2 ;
(56,384 real changes made, 1,257 to missing)

. replace afdcmb = afdcmb4 if qualChild >= 3 ;
(34,966 real changes made, 935 to missing)

. gen fsmb = 0 ;

. replace fsmb = fsmb1 if qualChild == 0 ;
(197,046 real changes made, 4,269 to missing)

. replace fsmb = fsmb2 if qualChild == 1 ;
(73,544 real changes made, 1,400 to missing)

. replace fsmb = fsmb3 if qualChild == 2 ;
(56,384 real changes made, 1,257 to missing)

. replace fsmb = fsmb4 if qualChild >= 3 ;
(34,966 real changes made, 935 to missing)

. gen minwage = fedminwge+stminwge ;
(7,861 missing values generated)

. *replace famsize = min(famsize,5) ;
. replace hhsize = min(hhsize-1-qualChild, 5)  ;
(361,940 real changes made)

. sort state year;

. by state year: gen oneobs = _n ;

. summ afdcmb3 if oneobs == 1 & year==1984, d ;

                           afdcmb3
-------------------------------------------------------------
      Percentiles      Smallest
 1%     215.2442       215.2442
 5%     284.7501        264.571
10%     367.7088       284.7501       Obs                  51
25%     517.9313        318.382       Sum of Wgt.          51

50%     719.7228                      Mean           722.4045
                        Largest       Std. Dev.      280.7619
75%     825.1027       1179.359
90%     1121.063       1186.085       Variance       78827.26
95%     1186.085       1188.327       Skewness       .5034909
99%      1560.52        1560.52       Kurtosis       3.238699

. gen temp = afdcmb3>r(mean) if year==1984;
(353,059 missing values generated)

. sort state;

. by state : egen afdcmb3GTmean = max(temp);

. tab afdcmb3GTmean ;

afdcmb3GTme |
         an |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    171,977       47.52       47.52
          1 |    189,963       52.48      100.00
------------+-----------------------------------
      Total |    361,940      100.00

. drop oneobs temp;

. foreach var in jobs limit asset medi prov child {;
  2.         gen byte wave_`var' = (year>=afdcwaiver`var');
  3.         replace wave_`var' = 0 if wave_`var'==. ;
  4.         gen byte waveXc_`var' = (wave_`var')*(qualChild>0) ;
  5.         };
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)

. gen byte anywave = (wave_jobs+wave_limit+wave_asset+wave_medi+wave_prov+wave_child)>0 ;

. gen byte anywaveXc = anywave*(qualChild>0) ;

. summ afdcwaiver* wave_* waveXc_* anywave anywaveXc;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
afdcwaiver~s |    223,267    1995.605    1.065952       1993       1997
afdcwaive~it |    228,019     1997.82    2.438162       1996       2012
afdcwaive~et |    258,712    1995.102    1.244309       1990       1997
afdcwaiver~i |    201,980    1995.129    1.266039       1993       1997
afdcwaiver~v |    232,197    1994.934    1.542398       1990       1997
-------------+---------------------------------------------------------
afdcwaiver~d |    285,639    1993.787    2.369369       1988       1997
   wave_jobs |    361,940    .3661104    .4817408          0          1
  wave_limit |    361,940    .3346798    .4718791          0          1
  wave_asset |    361,940    .4350832    .4957686          0          1
   wave_medi |    361,940    .3402608    .4737974          0          1
-------------+---------------------------------------------------------
   wave_prov |    361,940    .3888103    .4874808          0          1
  wave_child |    361,940    .5025667    .4999941          0          1
 waveXc_jobs |    361,940    .1794938    .3837658          0          1
waveXc_limit |    361,940    .1601619    .3667567          0          1
waveXc_asset |    361,940     .206689     .404931          0          1
-------------+---------------------------------------------------------
 waveXc_medi |    361,940    .1573686    .3641485          0          1
 waveXc_prov |    361,940    .1846245    .3879932          0          1
waveXc_child |    361,940    .2340001    .4233728          0          1
     anywave |    361,940     .553484    .4971319          0          1
   anywaveXc |    361,940    .2604106    .4388592          0          1

. egen minyear = rowmin(afdcwaiver*) ;
(48102 missing values generated)

. gen waiver1995 = 0 ;

. replace waiver1995 = 1 if minyear < 1995 & minyear!=. & minyear!=0;
(181,670 real changes made)

. tab waiver1995, missing;

 waiver1995 |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    180,270       49.81       49.81
          1 |    181,670       50.19      100.00
------------+-----------------------------------
      Total |    361,940      100.00

. drop minyear ;

. foreach a of numlist 24(4)52 {;
  2.         gen byte age_`a' = (age >= `a' & age <= `a'+3);
  3.         };

. summ age age_* ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
         age |    361,940     34.4756    7.305641         24         48
      age_24 |    361,940    .2308863    .4214004          0          1
      age_28 |    361,940    .1803227    .3844565          0          1
      age_32 |    361,940    .1550727    .3619744          0          1
      age_36 |    361,940    .1427336    .3498015          0          1
-------------+---------------------------------------------------------
      age_40 |    361,940    .1361192    .3429156          0          1
      age_44 |    361,940    .1256341     .331437          0          1
      age_48 |    361,940    .0292314    .1684547          0          1
      age_52 |    361,940           0           0          0          0

. *table year children [aw=wtsupp], c(mean age) ;
. gen byte hgc_11 = (hgc < 12) ;

. foreach e in 12 13 16 17 {;
  2.         gen byte hgc_`e' = (hgc == `e') ;
  3.         };

. summ hgc hgc_* ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
         hgc |    361,940    13.25494    1.901225         11         17
      hgc_11 |    361,940    .1258413    .3316709          0          1
      hgc_12 |    361,940    .3364397     .472492          0          1
      hgc_13 |    361,940    .2825855    .4502571          0          1
      hgc_16 |    361,940    .1774714    .3820677          0          1
-------------+---------------------------------------------------------
      hgc_17 |    361,940     .077662    .2676394          0          1

. *table year children [aw=wtsupp], c(mean hgc) ;
. *table year children [aw=wtsupp], c(mean hgc_11) ;
. gen byte white = race == 100 ;

. gen byte hispanic = hispan!=0 ;

. *tabstat white hispanic [aw=wtsupp], by(year) s(mean) c(v) ;
. gen byte divorced = marst == 3 | marst == 4 ;

. foreach c of numlist 0(1)3 {;
  2.         gen cI`c' = qualChild == `c' ;
  3.         };

. replace cI3 = 1 if qualChild > 3 ;
(11,211 real changes made)

. summ cI* ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
         cI0 |    361,940    .5444162     .498024          0          1
         cI1 |    361,940    .2031939    .4023762          0          1
         cI2 |    361,940    .1557827    .3626497          0          1
         cI3 |    361,940    .0966072    .2954225          0          1

. save singleWomen, replace ;
file singleWomen.dta saved

. */
> *;
. disp "`beginTime'" ;
DateTime: 16 Apr 2018 08:59:52

. disp "DateTime: $S_DATE $S_TIME";
DateTime: 16 Apr 2018 09:00:15

. log close ;
      name:  <unnamed>
       log:  3_SingleWomen_regPrep.log
  log type:  text
 closed on:  16 Apr 2018, 09:00:15
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
